package com.hbnu.exercise.net;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class TcpClientDemo02
{
    public static void main(String[] args)
    {
        try
        {
            Socket socket = new Socket("127.0.0.1", 8888);

            OutputStream out = socket.getOutputStream();
            InputStream in = socket.getInputStream();

            out.write("收到请回复, OVER!".getBytes());

            byte[] data = new byte[1024];
            int length = in.read(data);
            System.out.println(new String(data, 0, length));

            socket.close();
        } catch (IOException e)
        {
            e.printStackTrace();
        }

    }
}
